package org.game.msgBuilder;

import java.util.Collection;
import java.util.List;

import org.bean.FunctionSwitchDTO;
import org.game.protobuf.s2c.S2CLoginMsg.FunctionSwitch;
import org.game.protobuf.s2c.S2CLoginMsg.RespFunctionSwitch;
import org.game.protobuf.s2c.S2CShareMsg.ChangeType;

import com.google.common.collect.Lists;

/**
 * @author : DengYing
 * @CreateDate : 2018年2月8日 下午4:38:32
 * @Description ：Please describe this document
 */
public class FunctionSwitchMsgBuilder {

	public static FunctionSwitch buildFunctionSwitchMsg(FunctionSwitchDTO functionSwitchDT) {
		return FunctionSwitch.newBuilder().setSwitchType(functionSwitchDT.getType()).setOpen(functionSwitchDT.isOpen()).setCt(ChangeType.valueOf(functionSwitchDT.getAction().getCode())).build();
	}

	public static List<FunctionSwitch> buildFunctionSwitchMsg(Collection<FunctionSwitchDTO> list) {
		List<FunctionSwitch> arrays = Lists.newArrayList();
		for (FunctionSwitchDTO functionSwitchDTO : list) {
			arrays.add(buildFunctionSwitchMsg(functionSwitchDTO));
		}
		return arrays;
	}

	public static RespFunctionSwitch buildRespFunctionSwitch(Collection<FunctionSwitchDTO> list) {
		RespFunctionSwitch.Builder builder = RespFunctionSwitch.newBuilder();
		builder.addAllSwitchs(buildFunctionSwitchMsg(list));
		return builder.build();
	}
}
